home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98a.txt
/
000165_icon-group-sender _Wed Apr 15 13:04:21 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id NAA20416
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Wed, 15 Apr 1998 13:04:20 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA27990; Wed, 15 Apr 1998 13:04:19 -0700
Date: Wed, 15 Apr 1998 08:11:36 -0700
From: swampler@noao.edu (Steve Wampler)
Subject: Re: Tables of records
To: icon-group@optima.CS.Arizona.EDU
Message-Id: <swampler-9803151511.AA001617811@orpheus.gemini.edu>
In-Reply-To: <78201599.35340ec3@aol.com>
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1560
DLucido wrote:
> I am brand new to Icon (Just got the book this week) and I have been
> experimenting
> with some code to test my understanding. While the following is not in any
> doucumentation I have found, it works. I defined a record and created a table
> of
> records with the following code:
>
> record node(value,lchild,rchild)
>
> procedure main(arg)
>
> tree:=table()
> tree[1]:=node(2,3,"Hello")
> tree[2]:=node(5,6,"World")
> tree[3]:=node(0,1,"Oops")
>
> every i:=key(tree)do
> write(i,":",tree[i].rchild)
>
> end
>
> While the order of the keys in unpredictable, the code can store a table of
> records.
> Is this a feature or something that should be avoided?
>
> David Lucido
> dlucido@aol.com
Any variable in Icon (elements of lists, tables, and sets, as well as record fields,
are all variables) can hold any type in Icon. This is very much by design. The
only object that only holds a specific type is a character set (cset), which can
only hold characters [also by design].
By all means, don't avoid this.
The order is unpredictable because tables are really annotated sets, which,
like sets in general, are unordered. You can use the sort() function to obtain
values (and keys) from a table or set in a predetermined order.
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
The gods that smiled at your birth are now laughing openly. (Fortune Cookie)